package com.mujin.keji.collectionsystem.module.updata.viewmodel;

import android.arch.lifecycle.LiveData;
import android.arch.lifecycle.ViewModel;

import com.mujin.keji.collectionsystem.base.BaseDto;
import com.mujin.keji.collectionsystem.module.updata.dto.UploadDto;
import com.mujin.keji.collectionsystem.module.updata.repository.IUploadRepository;
import com.mujin.keji.collectionsystem.module.updata.repository.UploadRepository;
import com.mujin.keji.collectionsystem.module.updata.vo.UploadVo;

import java.io.File;
import java.util.List;

/**
 * 上传文件viewmodel
 *
 * @author weishixiong
 * @Time 2018-05-3
 */
public class UploadViewModel extends ViewModel {
    private LiveData<BaseDto<UploadDto>> liveData;

    private IUploadRepository repository;

    public LiveData<BaseDto<UploadDto>> getLiveData(UploadVo vo, List<File> fileList) {
        uploadUserFile(vo, fileList);
        return liveData;
    }
    /**
     * 上传单个案件的文件
     *
     * @param vo
     * @param fileList
     */
    private void uploadUserFile(UploadVo  vo, List<File> fileList) {
        repository = new UploadRepository();
        this.liveData = repository.uploadUserFile(vo, fileList);
    }
}
